import { Rule, RuleType } from '@midwayjs/decorator';
import { ConvenientType } from '../entity/ConvenientService';

export class LoginDto {
  @Rule(RuleType.string().required())
  username: string;
  @Rule(RuleType.string().required())
  password: string;
}

export class ChangePasswordDto {
  @Rule(RuleType.string().required())
  password: string;
  @Rule(RuleType.string().required())
  newPassword: string;
}

export class UserDto {
  @Rule(RuleType.string().required())
  username: string;
  @Rule(RuleType.string().required())
  password: string;
  @Rule(RuleType.number().required())
  departmentId: number;
  @Rule(RuleType.string().optional())
  nickname: string;
  @Rule(RuleType.string().optional())
  avatarUrl: string;
  @Rule(RuleType.string().optional())
  openid: string;
  @Rule(RuleType.string().optional())
  idcard: string;
}

export class DepartmentDto {
  @Rule(RuleType.string().required())
  name: string;

  @Rule(RuleType.string().optional())
  contact: string;

  @Rule(RuleType.string().optional())
  tel: string;
}

export class FlowDto {
  @Rule(RuleType.string().required())
  name: string;

  @Rule(RuleType.string().optional())
  convenientType: ConvenientType;

  @Rule(RuleType.array().min(1))
  nodes: FlowNodeDto[];
}

export class FlowNodeDto {
  @Rule(RuleType.string().required())
  name: string;
  @Rule(RuleType.string().required())
  role: string;
  @Rule(RuleType.number().required())
  userId: number;
}
